<?php

class Front_LoginController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
    	$membre = new Front_Model_DbTable_Membres();
    	$membres = $membre->fetchAll();
    	$this->view->membre = $membres;
    	
    }

    public function registerFormAction()
    {
        // action body
    }

    public function addAction()
    {
    	$form = new Front_Form_Register();
    	$this->view->form = $form;
    	
    	if ($this->getRequest()->isPost()){
    		$formData = $this->getRequest()->getPost();
    		if ($form->isValid($formData)){
    	
    			$login = $form->getValue('login');
    			$email = $form->getValue('email');
    			$password = $form->getValue('password');
    			$repassword = $form->getValue('repassword');
    			$pays = $form->getValue('pays');
    			$captcha = $form->getValue('captcha');
    			
    			$membre = new Front_Model_DbTable_Membres();
    			$membres = $membre->addMembre($login, $email, $password, $repassword, $pays);
//     			echo $membres; die('test');
    			$this->_redirect('front/index');
    		}else {
    			$form->populate($formData);
//     			echo $form->populate($formData); die('test');
    		}
    	}
    }


}